package com.liyong.res.producer;

/**
 * create by yongli on 2020-05-17 19:30
 * 这就是作为消息要发给kafka的消息格式
 * 必须要指定kafka的存储数据的方式
 */

public class MyProducerRecord<K, V> {
    private String topic;
    private Integer partition;
    private Long timestamp;
    private K key;
    private V value; // 就像知道它们的类型一样

    public MyProducerRecord() {
    }

    /**
     * 这个构造方法只关注最基本的信息
     * @param topic
     * @param key
     * @param value
     */
    public MyProducerRecord(String topic, K key, V value) {
        this.topic = topic;
        this.key = key;
        this.value = value;
    }

    public MyProducerRecord(String topic, Integer partition, K key, V value) {
        this.topic = topic;
        this.partition = partition;
        this.key = key;
        this.value = value;
    }

    public MyProducerRecord(String topic, Integer partition, Long timestamp, K key, V value) {
        this.topic = topic;
        this.partition = partition;
        this.timestamp = timestamp;
        this.key = key;
        this.value = value;
    }

}
